using Senparc.Weixin.Entities;
using Senparc.Weixin.MP.CommonAPIs;
using System;
namespace Senparc.Weixin.MP.AdvancedAPIs.MerChant
{
	public static class OrderApi
	{
		public static GetByIdOrderResult GetByIdOrder(string accessToken, string orderId)
		{
			string urlFormat = "https://api.weixin.qq.com/merchant/order/getbyid?access_token={0}";
			var data = new
			{
				order_id = orderId
			};
			return CommonJsonSend.Send<GetByIdOrderResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
		public static GetByFilterResult GetByFilterOrder(string accessToken, int status, long beginTime, long endTime)
		{
			string urlFormat = "https://api.weixin.qq.com/merchant/order/getbyfilter?access_token={0}";
			var data = new
			{
				status = status,
				begintime = beginTime,
				endtime = endTime
			};
			return CommonJsonSend.Send<GetByFilterResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
		public static WxJsonResult SetdeliveryOrder(string accessToken, string orderId, string deliveryCompany, string deliveryTrackNo, int needDelivery = 1, int isOthers = 0)
		{
			string urlFormat = "https://api.weixin.qq.com/merchant/order/setdelivery?access_token={0}";
			var data = new
			{
				order_id = orderId,
				delivery_company = deliveryCompany,
				delivery_track_no = deliveryTrackNo,
				need_delivery = needDelivery,
				is_others = isOthers
			};
			return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
		public static WxJsonResult CloseOrder(string accessToken, string orderId)
		{
			string urlFormat = "https://api.weixin.qq.com/merchant/order/close?access_token={0}";
			var data = new
			{
				order_id = orderId
			};
			return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, 10000, false);
		}
	}
}
